Skip to content

Conversation

TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Feb 25, 2025

Fixes #137508
Fixes #137554

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2025

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2025

HIR ty lowering was modified

cc @fmease

}

fn main() {
let _: dyn Tr + ?Foo();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have to do with parenthesized syntax. This also ICEs: + ?Foo<Assoc = ()>.

Please edit the test name so it's more clear what it's testing, add the issue number as a comment like:

// Fix for <https://github.com/issues....>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to mention explicitly:

Change the test to use + ?Foo<Assoc = ()> rather than the parentheses syntax.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks.

trait_def,
);
let trait_def = path.res.opt_def_id();
let assoc_item = trait_def.and_then(|trait_def_id| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave a comment here saying that we don't want to unwrap a trait def id if it resolves incorrectly.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2025
@compiler-errors
Copy link
Member

compiler-errors commented Feb 25, 2025

Actually, #137554 is the same issue, but with a different kind of item.

Instead of calling opt_def_id, please match on the Res::Def(DefKind::Trait, def_id). This will avoid ICEing in case the path resolves, but it resolves to the wrong kind of item. Then you can add a regression test for this too.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 25, 2025
@TaKO8Ki TaKO8Ki removed the request for review from compiler-errors February 25, 2025 20:00
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for #137554, and squash this into one commit.

Also no need to click the "request review" button; I'll review the PR when I have free time. All it does is give me an unnecessary notification.

let _: dyn Tr + ?Foo<Assoc = ()>;
//~^ ERROR: `?Trait` is not permitted in trait object types
//~| ERROR: cannot find trait `Foo` in this scope
//~| ERROR: the value of the associated type `Item` in `Tr` must be specifi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//~| ERROR: the value of the associated type `Item` in `Tr` must be specifi
//~| ERROR: the value of the associated type `Item` in `Tr` must be specified

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2025
rename ui tests

check if res is trait def

fix typo

regression test for rust-lang#137554
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 25, 2025

📌 Commit b7a5497 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 25, 2025
fmease added a commit to fmease/rust that referenced this pull request Feb 26, 2025
…rrors

Avoid collecting associated types for undefined trait

Fixes rust-lang#137508
Fixes rust-lang#137554
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang#134585 (remove `MaybeUninit::uninit_array`)
 - rust-lang#136187 (Use less CString in the examples of CStr.)
 - rust-lang#136457 (Expose algebraic floating point intrinsics)
 - rust-lang#137201 (Teach structured errors to display short `Ty<'_>`)
 - rust-lang#137620 (Fix `attr` cast for espidf)
 - rust-lang#137631 (Avoid collecting associated types for undefined trait)
 - rust-lang#137635 (Don't suggest constraining unstable associated types)
 - rust-lang#137642 (Rustc dev guide subtree update)
 - rust-lang#137660 (Update gcc submodule)
 - rust-lang#137670 (revert accidental change in get_closest_merge_commit)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang#134585 (remove `MaybeUninit::uninit_array`)
 - rust-lang#136187 (Use less CString in the examples of CStr.)
 - rust-lang#137201 (Teach structured errors to display short `Ty<'_>`)
 - rust-lang#137620 (Fix `attr` cast for espidf)
 - rust-lang#137631 (Avoid collecting associated types for undefined trait)
 - rust-lang#137635 (Don't suggest constraining unstable associated types)
 - rust-lang#137642 (Rustc dev guide subtree update)
 - rust-lang#137660 (Update gcc submodule)
 - rust-lang#137670 (revert accidental change in get_closest_merge_commit)
 - rust-lang#137671 (Make -Z unpretty=mir suggest -Z dump-mir as well for discoverability)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2fc8823 into rust-lang:master Feb 26, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 26, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
Rollup merge of rust-lang#137631 - TaKO8Ki:issue-137508, r=compiler-errors

Avoid collecting associated types for undefined trait

Fixes rust-lang#137508
Fixes rust-lang#137554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: missing associated_item_or_field_def_ids for DefId ICE: attempted .def_id() on invalid res: Err
5 participants